<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                xmlns:fn="http://java.sun.com/jsp/jstl/functions"
                template="/templates/ui.xhtml">

    <ui:define name="head">
        <script type="text/javascript" src="#{request.contextPath}/UI/support/pub.js"/>
        <script type="text/javascript">
            document.onkeydown = function TabReplace() {
                if (event.keyCode == 13) {
                    if (event.srcElement.tagName != 'BUTTON')
                        event.keyCode = 9;
                }
            }
            function doPopupWindow(obj) {
                var pkid = obj.parentNode.parentNode.parentNode.childNodes[0].childNodes[0].childNodes[0].innerHTML;
                var sfeature = "dialogwidth:850px; dialogheight:320px;center:yes;help:no;resizable:yes;scroll:no;status:no";
                var rtn = dialog("customerEdit.xhtml?pkid=" + pkid + "&amp;action=update", null, sfeature);
                if (rtn == "1") {
                    document.getElementById("tabview:form:doFlag").value = "1";
                    document.getElementById("tabview:form:qrybtn").click();
                }
            }
        </script>
        <style type="text/css">
            .col-95 {
                width: 95%;
            }

            .col-5 {
                width: 5%;
            }
        </style>
    </ui:define>
    <ui:define name="content">
        <div style="margin:5px">
            <p:tabView id="tabview" dynamic="true" cache="false" style="font-weight:normal;font-style:normal">
                <p:tab title="供货商信息管理">
                    <h:form id="form">
                        <div id="qrytable">
                            <p:focus for="custCode"/>
                            <p:growl id="msgs" showDetail="false"/>
                            <p:panel style="margin-top:10px">
                                <h:panelGrid columns="2" cellspacing="5" columnClasses="col-95,col-5">
                                    <h:panelGrid columns="4" cellspacing="5" style="text-align: right;">
                                        <h:outputLabel value="供货商编码:"/>
                                        <p:inputText id="custCode" value="#{customerAction.strCustCode}"
                                                     requiredMessage="必须输入供货商编码！"
                                                     size="30"/>
                                        <h:outputLabel value="供货商名称:"/>
                                        <p:inputText id="custName" value="#{customerAction.strCustName}" size="30"
                                                    requiredMessage="必须输入供货商名称！"/>
                                    </h:panelGrid>
                                    <h:panelGrid>
                                        <p:commandButton style="width:90px;" id="qrybtn" value="查询"
                                                         action="#{customerAction.queryCustomer}"
                                                         update="pdt,msgs">
                                        </p:commandButton>
                                    </h:panelGrid>
                                </h:panelGrid>
                            </p:panel>
                            <p:ajaxStatus style="height:18px;text-align:center">
                                <f:facet name="start">
                                    <h:graphicImage value="/images/ajaxloadingbar.gif"/>
                                </f:facet>
                                <f:facet name="complete">
                                    <h:outputText value=""/>
                                </f:facet>
                            </p:ajaxStatus>
                            <p:dataTable id="pdt" dynamic="true" style="width:100%;"
                                         value="#{customerAction.listCustomer}" var="record"
                                         rowKey="#{record.id}" selectionMode="single"
                                         selection="#{customerAction.selectedOaCustomerRecords}"
                                         paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                         paginator="true" rows="15" paginatorPosition="bottom"
                                         rowsPerPageTemplate="100,50,30,15,5"
                                         emptyMessage="没有查询到数据记录...">
                                <p:column headerText="Pkid" style="display:none;">
                                    <h:outputText style="display: none;" value="#{record.id}"/>
                                </p:column>
                                <p:column headerText="供货商编码">
                                    <h:outputText value="#{record.custCode}"/>
                                </p:column>

                                <p:column headerText="供货商名称">
                                    <h:outputText value="#{record.custName}"/>
                                </p:column>

                                <p:column headerText="联系人">
                                    <h:outputText value="#{record.custRelation}"/>
                                </p:column>

                                <p:column headerText="电话">
                                    <h:outputText value="#{record.custTele}"/>
                                </p:column>

                                <p:column headerText="手机">
                                    <h:outputText value="#{record.custMobile}"/>
                                </p:column>

                                <p:column headerText="Email">
                                    <h:outputText value="#{record.custEmail}"/>
                                </p:column>

                                <p:column headerText="状态">
                                <h:outputText value="#{customerAction.useStatus.valueOfAlias(record.isUse).title}"/>
                            </p:column>
                                <p:column headerText="操作" style="width:80px;text-align:center">
                                    <p:commandLink style="color:blue;align:center;" value="修改"
                                                   onclick="doPopupWindow(this);"/>
                                    <h:commandLink id="btnDelete" immediate="false"
                                                   onclick="if (confirm('确定删除 '+this.parentNode.parentNode.parentNode.childNodes[2].childNodes[0].innerHTML+'？')) return true;else return false;"
                                                   action="#{customerAction.cancelCustomer}"
                                                   update="pdt"
                                                   value="删除" style="margin-left: 7px;color:blue">
                                        <f:param name="pkid" value="#{record.id}"/>
                                    </h:commandLink>
                                </p:column>
                                <p:columnGroup type="footer">
                                    <p:row>
                                        <p:column colspan="10"
                                                  footerText="共查询到#{fn:length(customerAction.listCustomer)}笔记录"
                                                  style="text-align:right"/>
                                    </p:row>
                                </p:columnGroup>
                            </p:dataTable>
                        </div>
                    </h:form>
                </p:tab>
            </p:tabView>
        </div>
    </ui:define>
</ui:composition>